home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Text / WASTE / WASTE 1.1.2 Distribution / WASTE Headers / WASTE.h < prev   
Encoding:
C/C++ Source or Header  |  1995-10-12  |  30.0 KB  |  708 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C/C++ interface to the WASTE text engine
  5.  *
  6.  *    version 1.1.2 (September 1995)
  7.  *
  8.  *    Copyright (c) 1993-1995 Marco Piovanelli
  9.  *    All Rights Reserved
  10.  * 
  11.  */
  12.  
  13. #ifndef _WASTE_
  14. #define _WASTE_
  15.  
  16. #ifndef __CONDITIONALMACROS__
  17. #include <ConditionalMacros.h>
  18. #endif
  19.  
  20. #ifndef __TYPES__
  21. #include <Types.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifndef __QUICKDRAWTEXT__
  29. #include <QuickdrawText.h>
  30. #endif
  31.  
  32. #ifndef __QUICKDRAW__
  33. #include <Quickdraw.h>
  34. #endif
  35.  
  36. #ifndef __SCRIPT__
  37. #include <Script.h>
  38. #endif
  39.  
  40. #ifndef __TEXTUTILS__
  41. #include <TextUtils.h>
  42. #endif
  43.  
  44. #ifndef __TEXTEDIT__
  45. #include <TextEdit.h>
  46. #endif
  47.  
  48. #ifndef __DRAG__
  49. #include <Drag.h>
  50. #endif
  51.  
  52. #ifndef __LONGCOORDINATES__
  53. #ifndef _LongCoords_
  54. #include "LongCoords.h"
  55. #endif
  56. #endif
  57.  
  58. // if we're using a pre-2.1 version of the Universal Headers, define EventModifiers
  59. #ifndef UNIVERSAL_INTERFACES_VERSION
  60. typedef unsigned short EventModifiers;
  61. #endif
  62.  
  63. #if defined(powerc) || defined (__powerc)
  64. #pragma options align=mac68k
  65. #endif
  66.  
  67. #define WASTE11
  68.  
  69. /*    result codes */
  70.  
  71. enum {
  72.     weCantUndoErr            =    -10015,    /* undo buffer is clear (= errAECantUndo) */
  73.     weEmptySelectionErr        =    -10013,    /* selection range is empty (= errAENoUserSelection) */
  74.     weUnknownObjectTypeErr    =    -9478,    /* specified object type is not registered */
  75.     weObjectNotFoundErr        =    -9477,    /* no object found at specified offset */
  76.     weReadOnlyErr            =    -9476,    /* instance is read-only */
  77.     weUndefinedSelectorErr    =    -50        /* unknown selector (= paramErr) */
  78. };
  79.  
  80. /*    alignment styles */
  81.  
  82. enum {
  83.     weFlushLeft         =    -2,        /* flush left */
  84.     weFlushRight        =    -1,        /* flush right */
  85.     weFlushDefault        =     0,        /* flush according to system direction */
  86.     weCenter            =     1,        /* centered */
  87.     weJustify            =     2        /* fully justified */
  88. };
  89.  
  90. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  91.  
  92. enum {
  93.     weDoFont                =    0x0001,
  94.     weDoFace                =    0x0002,
  95.     weDoSize                =    0x0004,
  96.     weDoColor                =    0x0008,
  97.     weDoAll                    =    weDoFont + weDoFace + weDoSize + weDoColor,
  98.     weDoAddSize                =    0x0010,
  99.     weDoToggleFace            =    0x0020,
  100.     weDoReplaceFace            =    0x0040
  101. };
  102.  
  103. /*    values for the edge parameter in WEGetOffset etc. */
  104.  
  105. enum {
  106.     kLeadingEdge = -1,        /* point is on the leading edge of a glyph */
  107.     kTrailingEdge = 0,        /* point is on the trailing edge of a glyph */
  108.     kObjectEdge = 2            /* point is in the middle of an embedded object */
  109. };
  110.  
  111. /*    values for WEFeatureFlag feature parameter */
  112.  
  113. enum {
  114.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  115.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  116.     weFReadOnly            =    5,        /* disallow modifications */
  117.     weFUndo                =    6,        /* support WEUndo() */
  118.     weFIntCutAndPaste    =    7,        /* use intelligent cut-and-paste rules */
  119.     weFDragAndDrop        =    8,        /* support drag-and-drop text editing */
  120.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  121.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  122.     weFDrawOffscreen    =    11        /* draw text offscreen for smoother visual results */
  123. };
  124.  
  125. /*    values for WENew flags parameter */
  126.  
  127. enum {
  128.     weDoAutoScroll        =    1 << weFAutoScroll,
  129.     weDoOutlineHilite    =    1 << weFOutlineHilite,
  130.     weDoReadOnly        =    1 << weFReadOnly,
  131.     weDoUndo            =    1 << weFUndo,
  132.     weDoIntCutAndPaste    =    1 << weFIntCutAndPaste,
  133.     weDoDragAndDrop        =    1 << weFDragAndDrop,
  134.     weDoInhibitRecal    =    1 << weFInhibitRecal,
  135.     weDoUseTempMem        =    1 << weFUseTempMem,
  136.     weDoDrawOffscreen    =    1 << weFDrawOffscreen
  137. };
  138.  
  139. /*    values for WEFeatureFlag action parameter */
  140.  
  141. enum {
  142.     weBitToggle = -2,    /* toggles the specified feature */
  143.     weBitTest,            /* returns the current setting of the specified feature */
  144.     weBitClear,            /* disables the specified feature */
  145.     weBitSet            /* enables the specified feature */
  146. };
  147.  
  148. /*    selectors for WEGetInfo and WESetInfo */
  149.  
  150. enum {
  151.     weCharToPixelHook    =    'c2p ',    /* CharToPixel hook */
  152.     weClickLoop            =    'clik',    /* click loop callback */
  153.     weCurrentDrag        =    'drag',    /* drag currently being tracked from WEClick() */
  154.     weDrawTextHook        =    'draw', /* text drawing hook */
  155.     weLineBreakHook        =    'lbrk',    /* line breaking hook */
  156.     wePixelToCharHook    =    'p2c ', /* PixelToChar hook */
  157.     wePort                =    'port',    /* graphics port */
  158.     weRefCon            =    'refc',    /* reference constant for use by application */
  159.     weScrollProc        =    'scrl',    /* auto-scroll callback */
  160.     weText                =    'text',    /* text handle */
  161.     weTranslateDragHook =    'xdrg', /* drag translation callback */
  162.     weTSMDocumentID        =    'tsmd',    /* Text Services Manager document ID */
  163.     weTSMPreUpdate        =    'pre ',    /* Text Services Manager pre-update callback */
  164.     weTSMPostUpdate        =    'post'    /* Text Services Manager post-update callback */
  165. };
  166.  
  167. /*    values for WEInstallObjectHandler handlerSelector parameter */
  168.  
  169. enum {
  170.     weNewHandler        =    'new ',        /* new handler */
  171.     weDisposeHandler    =    'free',        /* dispose handler */
  172.     weDrawHandler        =    'draw',        /* draw handler */
  173.     weClickHandler        =    'clik'        /* click handler */
  174. };
  175.  
  176. /*    action kinds */
  177.  
  178. enum {
  179.     weAKNone            =    0,        /* null action */
  180.     weAKUnspecified        =    1,        /* action of unspecified nature */
  181.     weAKTyping            =    2,        /* some text has been typed in */
  182.     weAKCut                =    3,        /* the selection range has been cut */
  183.     weAKPaste            =    4,        /* something has been pasted */
  184.     weAKClear            =    5,        /* the selection range has been deleted */
  185.     weAKDrag            =    6,        /* drag and drop operation */
  186.     weAKSetStyle        =    7        /* some style has been applied to a text range */
  187. };
  188.  
  189. typedef struct OpaqueWEReference *WEReference;
  190. typedef struct OpaqueWEObjectReference *WEObjectReference;
  191. typedef Handle WESoupHandle;
  192. typedef short WEActionKind;
  193. typedef FourCharCode WESelector;
  194. typedef WEReference WEHandle;    /* obsolete, kept for backward compatibility */
  195.  
  196. typedef struct WERunInfo {
  197.     long                 runStart;    /* byte offset to first character of style run */
  198.     long                 runEnd;        /* byte offset past last character of style run */
  199.     short                 runHeight;    /* line height (ascent + descent + leading) */
  200.     short                 runAscent;    /* font ascent */
  201.     TextStyle             runStyle;    /* text attributes */
  202.     WEObjectReference    runObject;    /* either NULL or reference to embedded object */
  203. } WERunInfo;
  204.  
  205.  
  206. /*    callback prototypes */
  207.  
  208. typedef pascal Boolean (*WEClickLoopProcPtr)(WEReference we);
  209. typedef pascal void (*WEScrollProcPtr)(WEReference we);
  210. typedef pascal void (*WETSMPreUpdateProcPtr)(WEReference we);
  211. typedef pascal void (*WETSMPostUpdateProcPtr)(WEReference we,
  212.         long fixLength, long inputAreaStart, long inputAreaEnd,
  213.         long pinRangeStart, long pinRangeEnd);
  214. typedef pascal OSErr (*WETranslateDragProcPtr)(DragReference theDrag,
  215.         ItemReference theItem, FlavorType requestedType, Handle putDataHere);
  216. typedef pascal void (*WEDrawTextProcPtr)(Ptr pText, long textLength, Fixed slop,
  217.         JustStyleCode styleRunPosition, WEReference we);
  218. typedef pascal long (*WEPixelToCharProcPtr)(Ptr pText, long textLength, Fixed slop,
  219.         Fixed *pixelWidth, char *edge, JustStyleCode styleRunPosition, Fixed hPos, WEReference we);
  220. typedef pascal short (*WECharToPixelProcPtr)(Ptr pText, long textLength, Fixed slop,
  221.         long offset, short direction, JustStyleCode styleRunPosition, long hPos, WEReference we);
  222. typedef pascal StyledLineBreakCode (*WELineBreakProcPtr)(Ptr pText, long textLength,
  223.         long textStart, long textEnd, Fixed *textWidth, long *textOffset, WEReference we);
  224. typedef pascal void (*WEWordBreakProcPtr)(Ptr pText, short textLength, short offset,
  225.         char edge, OffsetTable breakOffsets, ScriptCode script, WEReference we);
  226. typedef pascal short (*WECharByteProcPtr)(Ptr pText, short textOffset, ScriptCode script,
  227.         WEReference we);
  228. typedef pascal short (*WECharTypeProcPtr)(Ptr pText, short textOffset, ScriptCode script, WEReference we);
  229. typedef pascal OSErr (*WENewObjectProcPtr)(Point *defaultObjectSize,
  230.         WEObjectReference obj);
  231. typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectReference obj);
  232. typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
  233.         WEObjectReference obj);
  234. typedef pascal Boolean (*WEClickObjectProcPtr)(Point hitPt, EventModifiers modifiers, unsigned long clickTime,
  235.         WEObjectReference obj);
  236.  
  237.  
  238. /*    UPP proc info */
  239.  
  240. enum {
  241.     uppWEClickLoopProcInfo = kPascalStackBased
  242.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  243.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  244. };
  245. enum {
  246.     uppWEScrollProcInfo = kPascalStackBased
  247.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  248. };
  249. enum {
  250.     uppWETSMPreUpdateProcInfo = kPascalStackBased
  251.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  252. };
  253. enum {
  254.     uppWETSMPostUpdateProcInfo = kPascalStackBased
  255.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  256.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*fixLength*/)))
  257.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long /*inputAreaStart*/)))
  258.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*inputAreaEnd*/)))
  259.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(long /*pinRangeStart*/)))
  260.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(long /*pinRangeEnd*/)))
  261. };
  262. enum {
  263.     uppWETranslateDragProcInfo = kPascalStackBased
  264.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  265.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(DragReference /*theDrag*/)))
  266.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(ItemReference /*theItem*/)))
  267.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(FlavorType /*requestedType*/)))
  268.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  269. };
  270. enum {
  271.     uppWEDrawTextProcInfo = kPascalStackBased
  272.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  273.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  274.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  275.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  276.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(WEReference /*we*/)))
  277. };
  278. enum {
  279.     uppWEPixelToCharProcInfo = kPascalStackBased
  280.         | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  281.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  282.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  283.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  284.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Fixed * /*pixelWidth*/)))
  285.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(char * /*edge*/)))
  286.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  287.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(Fixed /*hPos*/)))
  288.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEReference /*we*/)))
  289. };
  290. enum {
  291.     uppWECharToPixelProcInfo = kPascalStackBased
  292.         | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  293.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  294.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  295.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  296.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*offset*/)))
  297.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(short /*direction*/)))
  298.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  299.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(long /*hPos*/)))
  300.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEReference /*we*/)))
  301. };
  302. enum {
  303.     uppWELineBreakProcInfo = kPascalStackBased
  304.         | RESULT_SIZE(SIZE_CODE(sizeof(StyledLineBreakCode )))
  305.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  306.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  307.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long /*textStart*/)))
  308.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*textEnd*/)))
  309.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(Fixed * /*textWidth*/)))
  310.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(long * /*textOffset*/)))
  311.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEReference /*we*/)))
  312. };
  313. enum {
  314.     uppWEWordBreakProcInfo = kPascalStackBased
  315.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  316.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textLength*/)))
  317.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(short /*offset*/)))
  318.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(char /*edge*/)))
  319.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(OffsetTable * /*breakOffsets*/)))
  320.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  321.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEReference /*we*/)))
  322. };
  323. enum {
  324.     uppWECharByteProcInfo = kPascalStackBased
  325.         | RESULT_SIZE(SIZE_CODE(sizeof(short )))
  326.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  327.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textOffset*/)))
  328.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  329.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEReference /*we*/)))
  330. };
  331. enum {
  332.     uppWECharTypeProcInfo = kPascalStackBased
  333.         | RESULT_SIZE(SIZE_CODE(sizeof(short )))
  334.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  335.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textOffset*/)))
  336.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  337.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEReference /*we*/)))
  338. };
  339.  
  340.  
  341. enum {
  342.     uppWENewObjectProcInfo = kPascalStackBased
  343.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  344.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point * /*defaultObjectSize*/)))
  345.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  346. };
  347. enum {
  348.     uppWEDisposeObjectProcInfo = kPascalStackBased
  349.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  350.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  351. };
  352. enum {
  353.     uppWEDrawObjectProcInfo = kPascalStackBased
  354.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  355.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(const Rect * /*destRect*/)))
  356.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  357. };
  358. enum {
  359.     uppWEClickObjectProcInfo = kPascalStackBased
  360.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  361.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point /*hitPt*/)))
  362.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(EventModifiers /*modifiers*/)))
  363.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(unsigned long /*clickTime*/)))
  364.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  365. };
  366.  
  367.  
  368. /*    UPPs, New≈Proc macros & Call≈Proc macros */
  369.  
  370. /*
  371.     NOTE:
  372.     For compatibility with the Pascal version, Call≈Proc macros take the form:
  373.  
  374.         CallFooProc(..., userRoutine)
  375.  
  376.     instead of:
  377.  
  378.         CallFooProc(userRoutine, ...)
  379.  
  380. */
  381.  
  382. #if GENERATINGCFM
  383.  
  384. typedef UniversalProcPtr WEClickLoopUPP;
  385. typedef UniversalProcPtr WEScrollUPP;
  386. typedef UniversalProcPtr WETSMPreUpdateUPP;
  387. typedef UniversalProcPtr WETSMPostUpdateUPP;
  388. typedef UniversalProcPtr WETranslateDragUPP;
  389. typedef UniversalProcPtr WEDrawTextUPP;
  390. typedef UniversalProcPtr WEPixelToCharUPP;
  391. typedef UniversalProcPtr WECharToPixelUPP;
  392. typedef UniversalProcPtr WELineBreakUPP;
  393. typedef UniversalProcPtr WEWordBreakUPP;
  394. typedef UniversalProcPtr WECharByteUPP;
  395. typedef UniversalProcPtr WECharTypeUPP;
  396. typedef UniversalProcPtr WENewObjectUPP;
  397. typedef UniversalProcPtr WEDisposeObjectUPP;
  398. typedef UniversalProcPtr WEDrawObjectUPP;
  399. typedef UniversalProcPtr WEClickObjectUPP;
  400.  
  401. #define NewWEClickLoopProc(userRoutine) \
  402.     (WEClickLoopUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickLoopProcInfo, GetCurrentArchitecture())
  403. #define NewWEScrollProc(userRoutine) \
  404.     (WEScrollUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEScrollProcInfo, GetCurrentArchitecture())
  405. #define NewWETSMPreUpdateProc(userRoutine) \
  406.     (WETSMPreUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPreUpdateProcInfo, GetCurrentArchitecture())
  407. #define NewWETSMPostUpdateProc(userRoutine) \
  408.     (WETSMPostUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPostUpdateProcInfo, GetCurrentArchitecture())
  409. #define NewWETranslateDragProc(userRoutine) \
  410.     (WETranslateDragUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETranslateDragProcInfo, GetCurrentArchitecture())
  411. #define NewWEDrawTextProc(userRoutine) \
  412.     (WEDrawTextUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawTextProcInfo, GetCurrentArchitecture())
  413. #define NewWEPixelToCharProc(userRoutine) \
  414.     (WEPixelToCharUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEPixelToCharProcInfo, GetCurrentArchitecture())
  415. #define NewWECharToPixelProc(userRoutine) \
  416.     (WECharToPixelUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharToPixelProcInfo, GetCurrentArchitecture())
  417. #define NewWELineBreakProc(userRoutine) \
  418.     (WELineBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWELineBreakProcInfo, GetCurrentArchitecture())
  419. #define NewWEWordBreakProc(userRoutine) \
  420.     (WEWordBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEWordBreakProcInfo, GetCurrentArchitecture())
  421. #define NewWECharByteProc(userRoutine) \
  422.     (WECharByteUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharByteProcInfo, GetCurrentArchitecture())
  423. #define NewWECharTypeProc(userRoutine) \
  424.     (WECharTypeUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharTypeProcInfo, GetCurrentArchitecture())
  425. #define NewWENewObjectProc(userRoutine) \
  426.     (WENewObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWENewObjectProcInfo, GetCurrentArchitecture())
  427. #define NewWEDisposeObjectProc(userRoutine) \
  428.     (WEDisposeObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDisposeObjectProcInfo, GetCurrentArchitecture())
  429. #define NewWEDrawObjectProc(userRoutine) \
  430.     (WEDrawObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawObjectProcInfo, GetCurrentArchitecture())
  431. #define NewWEClickObjectProc(userRoutine) \
  432.     (WEClickObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickObjectProcInfo, GetCurrentArchitecture())
  433.  
  434. #define CallWEClickLoopProc(we, userRoutine) \
  435.     CallUniversalProc((userRoutine), uppWEClickLoopProcInfo, (we))
  436. #define CallWEScrollProc(we, userRoutine) \
  437.     CallUniversalProc((userRoutine), uppWEScrollProcInfo, (we))
  438. #define CallWETSMPreUpdateProc(we, userRoutine) \
  439.     CallUniversalProc((userRoutine), uppWETSMPreUpdateProcInfo, (we))
  440. #define CallWETSMPostUpdateProc(we, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  441.     CallUniversalProc((userRoutine), uppWETSMPostUpdateProcInfo, (we), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  442. #define CallWETranslateDragProc(theDrag, theItem, requestedType, putDataHere, userRoutine) \
  443.     CallUniversalProc((userRoutine), uppWETranslateDragProcInfo, (theDrag), (theItem), (requestedType), (putDataHere))
  444. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, we, userRoutine) \
  445.     CallUniversalProc((userRoutine), uppWEDrawTextProcInfo, (pText), (textLength), (slop), (styleRunPosition), (we))
  446. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, we, userRoutine) \
  447.     CallUniversalProc((userRoutine), uppWEPixelToCharProcInfo, (pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (we))
  448. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, we, userRoutine) \
  449.     CallUniversalProc((userRoutine), uppWECharToPixelProcInfo, (pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (we))
  450. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, we, userRoutine) \
  451.     CallUniversalProc((userRoutine), uppWELineBreakProcInfo, (pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (we))
  452. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, we, userRoutine) \
  453.     CallUniversalProc((userRoutine), uppWEWordBreakProcInfo, (pText), (textLength), (offset), (edge), (breakOffsets), (script), (we))
  454. #define CallWECharByteProc(pText, textOffset, script, we, userRoutine) \
  455.     CallUniversalProc((userRoutine), uppWECharByteProcInfo, (pText), (textOffset), (script), (we))
  456. #define CallWECharTypeProc(pText, textOffset, script, we, userRoutine) \
  457.     CallUniversalProc((userRoutine), uppWECharTypeProcInfo, (pText), (textOffset), (script), (we))
  458. #define CallWENewObjectProc(defaultObjectSize, obj, userRoutine) \
  459.     CallUniversalProc((userRoutine), uppWENewObjectProcInfo, (defaultObjectSize), (obj))
  460. #define CallWEDisposeObjectProc(obj, userRoutine) \
  461.     CallUniversalProc((userRoutine), uppWEDisposeObjectProcInfo, (obj))
  462. #define CallWEDrawObjectProc(destRect, obj, userRoutine) \
  463.     CallUniversalProc((userRoutine), uppWEDrawObjectProcInfo, (destRect), (obj))
  464. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, obj, userRoutine) \
  465.     CallUniversalProc((userRoutine), uppWEClickObjectProcInfo, (hitPt), (modifiers), (clickTime), (obj))
  466.  
  467. #else
  468.  
  469. typedef WEClickLoopProcPtr WEClickLoopUPP;
  470. typedef WEScrollProcPtr WEScrollUPP;
  471. typedef WETSMPreUpdateProcPtr WETSMPreUpdateUPP;
  472. typedef WETSMPostUpdateProcPtr WETSMPostUpdateUPP;
  473. typedef WETranslateDragProcPtr WETranslateDragUPP;
  474. typedef WEDrawTextProcPtr WEDrawTextUPP;
  475. typedef WEPixelToCharProcPtr WEPixelToCharUPP;
  476. typedef WECharToPixelProcPtr WECharToPixelUPP;
  477. typedef WELineBreakProcPtr WELineBreakUPP;
  478. typedef WEWordBreakProcPtr WEWordBreakUPP;
  479. typedef WECharByteProcPtr WECharByteUPP;
  480. typedef WECharTypeProcPtr WECharTypeUPP;
  481. typedef WENewObjectProcPtr WENewObjectUPP;
  482. typedef WEDisposeObjectProcPtr WEDisposeObjectUPP;
  483. typedef WEDrawObjectProcPtr WEDrawObjectUPP;
  484. typedef WEClickObjectProcPtr WEClickObjectUPP;
  485.  
  486. #define NewWEClickLoopProc(userRoutine) ((WEClickLoopUPP) (userRoutine))
  487. #define NewWEScrollProc(userRoutine) ((WEScrollUPP) (userRoutine))
  488. #define NewWETSMPreUpdateProc(userRoutine) ((WETSMPreUpdateUPP) (userRoutine))
  489. #define NewWETSMPostUpdateProc(userRoutine) ((WETSMPostUpdateUPP) (userRoutine))
  490. #define NewWETranslateDragProc(userRoutine) ((WETranslateDragUPP) (userRoutine))
  491. #define NewWEDrawTextProc(userRoutine) ((WEDrawTextUPP) (userRoutine))
  492. #define NewWEPixelToCharProc(userRoutine) ((WEPixelToCharUPP) (userRoutine))
  493. #define NewWECharToPixelProc(userRoutine) ((WECharToPixelUPP) (userRoutine))
  494. #define NewWELineBreakProc(userRoutine) ((WELineBreakUPP) (userRoutine))
  495. #define NewWEWordBreakProc(userRoutine) ((WEWordBreakUPP) (userRoutine))
  496. #define NewWECharByteProc(userRoutine) ((WECharByteUPP) (userRoutine))
  497. #define NewWECharTypeProc(userRoutine) ((WECharTypeUPP) (userRoutine))
  498. #define NewWENewObjectProc(userRoutine) ((WENewObjectUPP) (userRoutine))
  499. #define NewWEDisposeObjectProc(userRoutine) ((WEDisposeObjectUPP) (userRoutine))
  500. #define NewWEDrawObjectProc(userRoutine) ((WEDrawObjectUPP) (userRoutine))
  501. #define NewWEClickObjectProc(userRoutine) ((WEClickObjectUPP) (userRoutine))
  502.  
  503. #define CallWEClickLoopProc(we, userRoutine) \
  504.     (*(userRoutine))((we))
  505. #define CallWEScrollProc(we, userRoutine) \
  506.     (*(userRoutine))((we))
  507. #define CallWETSMPreUpdateProc(we, userRoutine) \
  508.     (*(userRoutine))((we))
  509. #define CallWETSMPostUpdateProc(we, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  510.     (*(userRoutine))((we), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  511. #define CallWETranslateDragProc(theDrag, theItem, requestedType, putDataHere, userRoutine) \
  512.     (*(userRoutine))((theDrag), (theItem), (requestedType), (putDataHere))
  513. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, we, userRoutine) \
  514.     (*(userRoutine))((pText), (textLength), (slop), (styleRunPosition), (we))
  515. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, we, userRoutine) \
  516.     (*(userRoutine))((pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (we))
  517. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, we, userRoutine) \
  518.     (*(userRoutine))((pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (we))
  519. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, we, userRoutine) \
  520.     (*(userRoutine))((pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (we))
  521. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, we, userRoutine) \
  522.     (*(userRoutine))((pText), (textLength), (offset), (edge), (breakOffsets), (script), (we))
  523. #define CallWECharByteProc(pText, textOffset, script, we, userRoutine) \
  524.     (*(userRoutine))((pText), (textOffset), (script), (we))
  525. #define CallWECharTypeProc(pText, textOffset, script, we, userRoutine) \
  526.     (*(userRoutine))((pText), (textOffset), (script), (we))
  527. #define CallWENewObjectProc(defaultObjectSize, obj, userRoutine) \
  528.     (*(userRoutine))((defaultObjectSize), (obj))
  529. #define CallWEDisposeObjectProc(obj, userRoutine) \
  530.     (*(userRoutine))((obj))
  531. #define CallWEDrawObjectProc(destRect, obj, userRoutine) \
  532.     (*(userRoutine))((destRect), (obj))
  533. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, obj, userRoutine) \
  534.     (*(userRoutine))((hitPt), (modifiers), (clickTime), (obj))
  535.  
  536. #endif
  537.  
  538.  
  539. /*    WASTE public calls */
  540.  
  541. #ifdef __cplusplus
  542. extern "C" {
  543. #endif
  544.  
  545. /*    creation and destruction */
  546.  
  547. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, short flags, WEReference *we);
  548. pascal void WEDispose(WEReference we);
  549.  
  550. /*    getting variables */
  551.  
  552. pascal Handle WEGetText(WEReference we);
  553. pascal short WEGetChar(long offset, WEReference we);
  554. pascal long WEGetTextLength(WEReference we);
  555. pascal long WECountLines(WEReference we);
  556. pascal long WEGetHeight(long startLine, long endLine, WEReference we);
  557. pascal void WEGetSelection(long *selStart, long *selEnd, WEReference we);
  558. pascal void WEGetDestRect(LongRect *destRect, WEReference we);
  559. pascal void WEGetViewRect(LongRect *viewRect, WEReference we);
  560. pascal Boolean WEIsActive(WEReference we);
  561. pascal long WEOffsetToLine (long offset, WEReference we);
  562.  
  563. /*    setting variables */
  564.  
  565. pascal void WESetSelection(long selStart, long selEnd, WEReference we);
  566. pascal void WESetDestRect(const LongRect *destRect, WEReference we);
  567. pascal void WESetViewRect(const LongRect *viewRect, WEReference we);
  568.  
  569. /*    accessing style run information */
  570.  
  571. pascal Boolean WEContinuousStyle(short *mode, TextStyle *ts, WEReference we);
  572. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEReference we);
  573.  
  574. /*    converting byte offsets to screen position and vice versa */
  575.  
  576. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEReference we);
  577. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEReference we);
  578.  
  579. /*    finding words and lines */
  580.  
  581. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEReference we);
  582. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEReference we);
  583.  
  584. /*    making a copy of a text range */
  585.  
  586. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup, WEReference we);
  587.  
  588. /*    getting and setting the alignment style */
  589.  
  590. pascal char WEGetAlignment(WEReference we);
  591. pascal void WESetAlignment(char alignment, WEReference we);
  592.  
  593. /*    recalculating line breaks, drawing and scrolling */
  594.  
  595. pascal OSErr WECalText(WEReference we);
  596. pascal void WEUpdate(RgnHandle updateRgn, WEReference we);
  597. pascal void WEScroll(long hOffset, long vOffset, WEReference we);
  598. pascal void WESelView(WEReference we);
  599.  
  600. /*    handling activate / deactivate events */
  601.  
  602. pascal void WEActivate(WEReference we);
  603. pascal void WEDeactivate(WEReference we);
  604.  
  605. /*     handling key-down events */
  606.  
  607. pascal void WEKey(short key, EventModifiers modifiers, WEReference we);
  608.  
  609. /*    handling mouse-down events and mouse tracking */
  610.  
  611. pascal void WEClick(Point hitPt, EventModifiers modifiers, unsigned long clickTime, WEReference we);
  612.  
  613. /*    adjusting the cursor shape */
  614.  
  615. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEReference we);
  616.  
  617. /*    blinking the caret */
  618.  
  619. pascal void WEIdle(unsigned long *maxSleep, WEReference we);
  620.  
  621. /*    modifying the text and the styles */
  622.  
  623. pascal OSErr WEInsert(const void *pText, long textLength, StScrpHandle hStyles, WESoupHandle hSoup, WEReference we);
  624. pascal OSErr WEDelete(WEReference we);
  625. pascal OSErr WESetStyle(short mode, const TextStyle *ts, WEReference we);
  626. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEReference we);
  627. pascal OSErr WEUseText(Handle hText, WEReference we);
  628.  
  629. /*    undo */
  630.  
  631. pascal OSErr WEUndo(WEReference we);
  632. pascal void WEClearUndo(WEReference we);
  633. pascal WEActionKind WEGetUndoInfo(Boolean *redoFlag, WEReference we);
  634. pascal Boolean WEIsTyping(WEReference we);
  635.  
  636. /*    keeping track of changes */
  637.  
  638. pascal unsigned long WEGetModCount(WEReference we);
  639. pascal void WEResetModCount(WEReference we);
  640.  
  641. /*    embedded objects */
  642.  
  643. pascal OSErr WEInstallObjectHandler(FlavorType objectType, WESelector handlerSelector, UniversalProcPtr handler, WEReference we);
  644. pascal OSErr WEInsertObject(FlavorType objectType, Handle objectDataHandle, Point objectSize, WEReference we);
  645. pascal OSErr WEGetSelectedObject(WEObjectReference *obj, WEReference we);
  646. pascal long WEFindNextObject(long offset, WEObjectReference *obj, WEReference we);
  647.  
  648. /*    accessing embedded object attributes */
  649.  
  650. pascal FlavorType WEGetObjectType(WEObjectReference obj);
  651. pascal Handle WEGetObjectDataHandle(WEObjectReference obj);
  652. pascal Point WEGetObjectSize(WEObjectReference obj);
  653. pascal WEReference WEGetObjectOwner(WEObjectReference obj);
  654. pascal long WEGetObjectRefCon(WEObjectReference obj);
  655. pascal void WESetObjectRefCon(WEObjectReference obj, long refCon);
  656.  
  657. /*    clipboard operations */
  658.  
  659. pascal OSErr WECut(WEReference we);
  660. pascal OSErr WECopy(WEReference we);
  661. pascal OSErr WEPaste(WEReference we);
  662. pascal Boolean WECanPaste(WEReference we);
  663.  
  664. /*    Drag Manager support */
  665.  
  666. pascal RgnHandle WEGetHiliteRgn(long rangeStart, long rangeEnd, WEReference we);
  667. pascal OSErr WETrackDrag(DragTrackingMessage message, DragReference drag, WEReference we);
  668. pascal OSErr WEReceiveDrag(DragReference drag, WEReference we);
  669. pascal Boolean WECanAcceptDrag(DragReference drag, WEReference we);
  670. pascal Boolean WEDraggedToTrash(DragReference drag);
  671.  
  672. /*    Script Manager utilities */
  673.  
  674. pascal short WECharByte(long offset, WEReference we);
  675. pascal short WECharType(long offset, WEReference we);
  676.  
  677. /*    Text Services Manager support */
  678.  
  679. pascal OSErr WEInstallTSMHandlers(void);
  680. pascal OSErr WERemoveTSMHandlers(void);
  681. pascal void WEStopInlineSession(WEReference we);
  682.  
  683. /*    additional features */
  684.  
  685. pascal short WEFeatureFlag(short feature, short action, WEReference we);
  686. pascal OSErr WEGetInfo(WESelector selector, void *info, WEReference we);
  687. pascal OSErr WESetInfo(WESelector selector, const void *info, WEReference we);
  688.  
  689. /*    long coordinate utilities */
  690.  
  691. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  692. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  693. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  694. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  695. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  696. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  697. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  698.  
  699. #ifdef __cplusplus
  700. }
  701. #endif
  702.  
  703. #if defined(powerc) || defined (__powerc)
  704. #pragma options align=reset
  705. #endif
  706.  
  707. #endif
  708.